<?php
/*
class Pfile extends BasePfile
{
    public function findByWords(array $words)
    {
        $q = ORMQuery::selectBuilder()
            ->from('Pfile pf');
        foreach($words as $word) {
            $word = trim($word);
			$q ->orWhere('pf.name LIKE ?','%' . $word . '%');
			$q ->orWhere('pf.location LIKE ?','%' . $word . '%');
			$q ->orWhere('pf.source LIKE ?','%' . $word . '%');
        }
        return $q->fetchAll('Pfile');
    }
    
    public function getFile($file)
    {
        $folder = Pfolder::getFolder(dirname($file));
        if (is_null($folder)) {
            throw new Exception('Cannot find folder '.dirname($file).' for file: ' . $file);
        }
        $fileObj = new Pfile();
        return $fileObj->getByParams(array('folder_id' => $folder->id, 'name' => basename($file)));
    }

    public static function readDocumentorFile($file)
    {
        $xml = simplexml_load_file($file);
        return (string)$xml->parent->source;
    }

    public function getRelativePath(Folder $folder)
    {
        $baseDir = $folder->path;
        $path = substr($this->Folder->path, strlen($baseDir) + 1);
        return $path . PATH_SEP . $this->name;
    }
	
	public function getLocation()
    {
        return $this->Folder->getLocation() . $this->name;
    }

    public function getById($id)
    {
        return parent::getById($id, __CLASS__);
    }
    
    public function getByParams( $params, $type = self::ONE_RECORD, $limit = null )
    {
        return parent::getByParams( $params, $type, $limit, __CLASS__);
    }
    
    public function getAll( $limit = null )
    {
        return parent::getAll( $limit, __CLASS__ );
    }

    public static function saveIfNotExists($params = null)
    {
        return parent::saveIfNotExists($params, __CLASS__);
    }
}
*/